package cs342.uwosh.edu.ContactsApp;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class ContactsDatabaseHelper extends SQLiteOpenHelper{
	
	static final String TABLE_CONTACTS = "contacts";
	static final String COL_ID = "_id";
	static final String COL_NAME = "name";
	static final String COL_ADDRESS = "address";
	static final String COL_HOME_PHONE_NUMBER = "home_phone";
	static final String COL_CELL_PHONE_NUMBER = "cell_phone";
	static final String COL_ALTERNATE_PHONE_NUMBER = "alt_phone";
	static final String COL_EMAIL = "email";
	static final String COL_COMMENT = "comment";
	//private static final String DATABASE_NAME = "contacts.db";
    private static final String DATABASE_CREATE = "create table " 
    				+ TABLE_CONTACTS + "( " + 
    						COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
    						COL_NAME + " text NOT NULL," +
    						COL_ADDRESS + " text," +
    						COL_HOME_PHONE_NUMBER + " text," +
    						COL_CELL_PHONE_NUMBER + " text," +
    						COL_ALTERNATE_PHONE_NUMBER + " text," +
    						COL_EMAIL + " text," +
    						COL_COMMENT + " text)";
    
    public ContactsDatabaseHelper(Context context) {
		super(context,TABLE_CONTACTS,null,1);
	}
    
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		db.execSQL(DATABASE_CREATE);
	}
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		db.execSQL("DROP TABLE IF EXISTS" + TABLE_CONTACTS);
		onCreate(db);
	}
}
